<script type="text/javascript">
function generate_code(){
    $.post("<?php echo $this->Html->url(array("action"=>"generate_code")) ?>", function(data){
        $("#code").val(data);
        $("#code2").val(data);
    });
    return false;
}
$(document).ready(function(){
    generate_code();
});

</script>
<div id="content">
	<!--  start page-heading -->
	<div id="page-heading">
		<h1>
        Add Gift Card
    </h1>
	</div>
	<!-- end page-heading -->
	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
  	<tr>
  		<th rowspan="3" class="sized">
          <?php echo $this->Html->image('/images/shared/side_shadowleft.jpg', array('width' => '20', 'height' => '300', 'alt' => '')); ?>
      </th>
  		<th class="topleft"></th>
  		<td id="tbl-border-top">&nbsp;</td>
  		<th class="topright"></th>
  		<th rowspan="3" class="sized">
          <?php echo $this->Html->image('/images/shared/side_shadowright.jpg', array('width' => '20', 'height' => '300', 'alt' => '')); ?>
      </th>
  	</tr>
  	<tr>
  		<td id="tbl-border-left"></td>
  		<td>
  		<!--  start content-table-inner ...................................................................... START -->
    		<div id="content-table-inner">
      			<!--  start table-content  -->
      			<div id="table-content">
                  <?php echo $this->Form->create('Gift');?>
                    <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                        <tr>
                            <th valign="top">Code:</th>
                            <td>
                                <?php
                                    echo $this->Form->input('v_code', array(
                                                        'label'     => false,
                                                        'div'       => false,
                                                        "id"        =>"code",
                                                        'disabled'  =>"disabled",
                                                        'class'     => 'input-form med')
                                        );     
                                ?> 
                                <?php
                                    echo $this->Form->input('code', array(
                                                        'label'     => false,
                                                        'div'       => false,
                                                        "id"        =>"code2",
                                                        'type'  =>"hidden",
                                                        'class'     => 'input-form med')
                                        );     
                                ?> 
                                <a href="#" onclick="return generate_code()" class="button">Generate code</a>
                            </td>
                            <td></td> 
                        </tr>
                    		<tr>
                    			 <th valign="top">Name :</th>
                    			 <td>
                              <?php 
                              		echo $this->Form->input('Gift.name', array('label' => false, 'div' => false, 'class' => 'inp-form'));
                              ?>      
                           </td>
                    			 <td></td>
                    		</tr>
                    		<!--<tr>
                    			 <th valign="top">Value :</th>
                    			 <td>
                              <?php 
                              		echo '$ '.$this->Form->input('Gift.value', array('label' => false, 'div' => false, 'class' => 'inp-form'));
                              ?>      
                           </td>
                    			 <td></td>
                    		</tr>-->
                    		<tr>
                    			 <th valign="top">Expiry Date :</th>
                    			 <td>
                              <?php 
                              		echo $this->Form->input('Gift.expiry', array('label' => false, 'div' => false, 'class' => 'chosen med', 'style' => 'width:148px'));
                              ?>      
                           </td>
                    			 <td></td>
                    		</tr>
                        <tr>
                        	<th>&nbsp;</th>
                        	<td valign="top">
                                <?php echo $this->Form->submit(__('Submit', true), array('label' => false, 'div' => false, 'class' => 'submit-button'));?>
                         		    <a href="#" onclick="history.back(-1)" class="cancel-button">Cancel</a>
                          </td>
                        	<td></td>
                        </tr>
                      </table>
                    <?php echo $this->Form->end(); ?>
        		</div>
      <!--  end content-table  -->
    		</div>
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>

</div>
